﻿using System.Drawing;
using SlimDX;

namespace InsTron
{
    class WallSegment
    {
        private int playerIdx;
        private Vector3 direction;
        private float length;

        public Vector3 Begin { get; private set; }
        public Vector3 End { get; private set; }

        public bool IsHorizontal
        {
            get { return direction.X != 0.0f; }
        }
        public bool IsVertical
        {
            get { return !IsHorizontal; }
        }


        public WallSegment(int playerIdx, Vector3 begin, Vector3 direction)
        {
            this.playerIdx = playerIdx;
            this.direction = direction;
            length = 0.0f;
            Begin = begin;
            End = begin;
        }


        public void Extend(float length)
        {
            End += direction * length;
            this.length += length;
        }


        public Matrix GetTransformationMatrix()
        {
            return Matrix.Scaling(length, 1.0f, length) * Matrix.Translation((Begin + End) / 2.0f);
        }


        public Color4 GetColor()
        {
            return new Color4(Settings.BikeParameters[playerIdx].Color);
        }
    }

}
